﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using DemoQLKhoSX.Library;

namespace DemoQLKhoSX.DatabaseAccessLayer
{
    public class UserDAO
    {
        private DBConnection conn;

        /// <constructor>
        /// Constructor UserDAO
        /// </constructor>
        public UserDAO()
        {
            conn = new DBConnection();
        }
        /// <method>
        /// Get User by username and pass and return DataTable
        /// </method>
        public DataTable searchByUNPA(string _username,string _password)
        {
            string query = string.Format("select * from [t01_user] " +
        "where username like @user or password " +
        "like @pass ");
            SqlParameter[] sqlParameters = new SqlParameter[2];
            sqlParameters[0] = new SqlParameter("@user", SqlDbType.VarChar);
            sqlParameters[0].Value = Convert.ToString(_username);
            sqlParameters[1] = new SqlParameter("@pass", SqlDbType.VarChar);
            sqlParameters[1].Value = Convert.ToString(_password);
            return conn.executeSelectQuery(query, sqlParameters);
        }
    }
}
